#ifndef _ARRAY_LIST_H
#define _ARRAY_LIST_H

#define DEFAULT_CAPACITY 20
#define SIZE_INCREMENTATION_FACTOR 2

/**
	ArrayList implementation. Use new_array_list(...) method for constructor.
	When constructing a new object of this type, you must pass a pointer to a
	comparison function that matches signature int (*comp)(void*,void*). This will
	be used for, for example the sort operations, and for operations to retrieve
	an index, given the object. Three comparisons functions are defined by default:
		* array_list_strcmp = for char* comparisons.
		* array_list_adrcmp = for address comparisons of the pointers.
		* array_list_intcmp = for integer comparisons.

	Everytime you call a method to edit the ArrayList, make sure to add a pointer
	to the list itself as an argument.

	@author
		Mikael Guldborg Rask Andersen
	@version
		18/02/2011: Original
		19/02/2011: Added heap sort algorithm
*/
struct stArrayList_t {
	void** collection;
	int size;
	int capacity;
	int (*comp)(void*, void*);
};

/* Constructor */
struct stArrayList_t* ArrayList_New(int (*comp)(void*, void*));
struct stArrayList_t* ArrayList_NewWithSize(int (*comp)(void*, void*), int capacity);

/* Public Methods */
void ArrayList_Insert(struct stArrayList_t* list, int index, void* element);
void ArrayList_Add(struct stArrayList_t* list, void* element);
void ArrayList_Clear(struct stArrayList_t* list);
int ArrayList_Contains(struct stArrayList_t* list, void* element);
void* ArrayList_Get(struct stArrayList_t* list, int index);
int ArrayList_IndexOf(struct stArrayList_t* list, void* element);
int ArrayList_IsEmpty(struct stArrayList_t* list);
void* ArrayList_RemoveAt(struct stArrayList_t* list, int index);
void* ArrayList_Remove(struct stArrayList_t* list, void* element);
int ArrayList_GetSize(struct stArrayList_t* list);
void ArrayList_Set(struct stArrayList_t* list, int index, void* element);
void ArrayList_BubbleSort(struct stArrayList_t* list);
void ArrayList_HeapSort(struct stArrayList_t* list);
void** ArrayList_CopyData(struct stArrayList_t* list);
void ArrayList_Finalize(struct stArrayList_t* list);

/* Default Compare Functions */
int ArrayList_StringComparison(char* one, char* two);
int ArrayList_AddressComparison(void* one, void* two);
int ArrayList_IntegerComparison(int* one, int* two);

#endif /* _ARRAY_LIST_H */
